package cn.lijiajia3515.cairo.system.config;

import cn.lijiajia3515.cairo.system.framework.minio.MinioProperties;
import io.minio.MinioClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MinioConfig {

	@ConfigurationProperties(prefix = "minio")
	@Bean
	MinioProperties minioProperties() {
		return new MinioProperties();
	}

	@Bean
	public MinioClient minioClient(MinioProperties properties) {
		return MinioClient.builder().endpoint(properties.getEndpoint()).credentials(properties.getUsername(), properties.getPassword())
			.build();
	}
}
